from rest_framework import serializers

from .exam_models import ExamContent, ExamHistory, ExamScore


class ExamContentSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = ExamContent
        fields = ['examName', 'examContent', 'optionA', 'optionB', 'optionC', 'optionD', 'examAnswer']


class ExamNameSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = ExamContent
        fields = ['examName']


# 答题记录历史序列化对象
class ExamHistorySerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = ExamHistory
        fields = ['userId', 'examName', 'examContent', 'userChosen', 'examAnswer', 'addTime']


class ExamScoreSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = ExamScore
        fields = ['userId', 'examName', 'examScore', 'addTime']
